<html>
<!-- =====================================================================

  File:      ErrorPage.htm for Adventure Works Cycles Storefront Sample
  Summary:   Self-documentation for application
  Date:	     June 16, 2003

=====================================================================

  This file is part of the Microsoft SQL Server Code Samples.
  Copyright (C) Microsoft Corporation.  All rights reserved.

This source code is intended only as a supplement to Microsoft
Development Tools and/or on-line documentation.  See these other
materials for detailed information regarding Microsoft code samples.

THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
PARTICULAR PURPOSE.

======================================================= -->
    <head>
        <title>Adventure Works Cycles Store Documentation</title>
        <link rel="stylesheet" href="style.css">
    </head>
    <body class="NormalIndent">
        <h1>
            ErrorPage.aspx Page
        </h1>
        <b>Description:</b> The ErrorPage.aspx page provides a custom error message 
        that is displayed to users anytime an unhandled exception occurs within the 
        application. Click the above links to view source/information about the various 
        components/user controls/stored procedures used to build it.
        <br>
        <br>
        <b>Implementation Notes:</b> Custom error handling is a built-in feature of 
        ASP.NET. To enable this feature, Adventure Works Cycles simply added a "customErrors" 
        configuration section to the Adventure Works Cycles's web.config file:
        <br>
        <br>
        <FONT color="#0000ff"><FONT color="#000000">&nbsp;&nbsp;&nbsp; </FONT>&lt;</FONT><FONT color="maroon">customErrors</FONT>
        mode="On" defaultRedirect="ErrorPage.aspx"<FONT color="blue">/&gt;</FONT>
        <BR>
        <br>
        <br>
        This configuration entry indicates that the "ErrorPage.aspx" page should be 
        used by default whenever an unhandled exception occurs during the 
        application.&nbsp; Although we are not taking direct advantage of it here, we 
        could have&nbsp;optionally&nbsp;added additional entries to&nbsp;send different 
        error messages back to the client depending on the type of errors that 
        occurred:&nbsp;
        <br>
        <br>
        <FONT color="#0000ff">
            <BR>
            <FONT color="#000000">&nbsp;&nbsp;&nbsp; </FONT><FONT color="blue">&lt;</FONT><FONT color="maroon">customErrors</FONT><FONT color="#000000">
                mode="On" defaultRedirect="ErrorPage.aspx"</FONT><FONT color="blue">&gt;</FONT>
            <BR>
            <FONT color="#000000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </FONT><FONT color="blue">
                &lt;</FONT><FONT color="maroon">error</FONT><FONT color="#000000"> statusCode="404" 
                redirect="adminmessage.htm"</FONT><FONT color="blue">/&gt;</FONT>
            <BR>
            <FONT color="#000000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </FONT><FONT color="blue">
                &lt;</FONT><FONT color="maroon">error</FONT><FONT color="#000000"> statusCode="403" 
                redirect="noaccessallowed.htm"</FONT><FONT color="blue">/&gt;</FONT>
            <BR>
            <FONT color="#000000">&nbsp;&nbsp;&nbsp; </FONT><FONT color="blue">&lt;/</FONT><FONT color="maroon">customErrors</FONT><FONT color="blue">&gt;</FONT>
            <BR>
        </FONT>
        <br>
        <br>
        For example, the above configuration settings indicate that browsers should be 
        redirected to the "adminmessage.htm" page when an HTTP Status Code of 404 is 
        returned (for example: a missing file).&nbsp; It also indicates that browsers 
        should be redirected to "noaccessallowed.htm" when an HTTP Status Code of 403 
        is returned (for example: an illegal attempt to access a resource).
        <br>
        <br>
        The &lt;customErrors&gt; configuration section also supports a "mode" 
        attribute that supports three values: "Off", "On", and "RemoteOnly".&nbsp; 
        "Off" will disable custom errors and instead send back an exception stack trace 
        when an unhandled exception occurs.&nbsp; Although this is very useful when 
        debugging applications, it is not very user-friendly for customers.&nbsp; "On" 
        indicates that custom error pages should always be used -- for all 
        clients.&nbsp; "RemoteOnly" is a hybrid mode that will ensure that customers 
        who browse the application from a remote machine will see custom error 
        messages, whereas users on the local server machine (for example: administrator 
        and developers) will see detailed error stack traces.
    </body>
</html>
